<template>
	<div class="aid">
		<div class="base">
			<p class="fixed-top">
				{{ importText.name }}
				<a-icon @click="closeFunction" type="close" />
			</p>
			<div class="main">
				<a-form :form="form">
					<a-form-model-item label="文件上传">
						<a-upload name="file" :action="requestUrl + importText.url" accept=".xlsx,application/vnd.ms-excel"
						:headers="{ ticket: token }" @change="uploadChange" :fileList="fileList">
							<a-button v-if="fileList.length==0">
								<a-icon type="upload" />
								文件选择
							</a-button>
						</a-upload>
					</a-form-model-item>
					<a-form-model-item label="模板下载">
						<div style="color:blue;cursor: pointer;" @click="download()">下载</div>
					</a-form-model-item>
					<a-form-item class="fixed-bottom">
						<!-- <a-button type="primary" @click="handleSubmit" :loading="loading">完成</a-button> -->
						<a-button style="margin-left: 10px;" @click="closeFunction">关闭</a-button>
					</a-form-item>
				</a-form>
			</div>
		</div>
	</div>
</template>

<script>
import {
	DoGetActivityMemberTypeListCommon,
	UserActivityMemberDoImportFormText,
	ManageActivityMemberDoImportFormText,
	DoAddActivityMember,
	GetActivityTypePrizeListCommon,
	UserDoAddActivityMemberPrize,
	AddActivityMemberPrize,
	DoGetSemesterListCommon
} from '@/api/follow';
import Cache from '@/utils/cache';
export default {
	props: {
		importText: Object
	},
	watch: {
		importText: function(importText) {
			
		}
	},
	data() {
		return {
			seStatus:true,
			semesterID:'',
			importIf: false,
			importData: [],
			fileList: [],
			loading: false,
			formLayout: 'horizontal',
			form: this.$form.createForm(this, {
				name: 'coordinated'
			}),
			// form:{
			// 	semesterID:''
			// },
			ActivityMemberTypeList: [],
			ActivityTypePrizeList: [],
			requestUrl: this.global.requestUrl,
			loadUrl: this.global.loadUrl,
			token: Cache.get('token'),
			SemesterList:[]
		};
	},
	methods: {
		download(){
			window.open(this.loadUrl+this.importText.href,'_blank')
		},
		fileload() {
			window.open(this.loadUrl + this.importText.href, '_blank');
		},
		uploadChange(info) {
			let { fileList } = info;
			const status = info.file.status;
			if (status === 'done') {
				if (info.file.response.code == 0) {
					this.$message.success(info.file.response.msg);
					this.fileList = [...fileList]; //重点
					// setTimeout((res)=>{
					// 	this.fileList = []
					// },500)
				} else {
					this.$message.error(info.file.response.msg);
					this.fileList = this.fileList.splice(this.fileList.length - 1, 1);
				}
			}
			this.fileList = [...fileList]; //重点
		},
		closeFunction(data) {
			this.importIf = false;
			this.fileList = []
			this.$emit('closeFun', 1);
		},
		handleRemove(file) {
			const index = this.fileList.indexOf(file);
			const newFileList = this.fileList.slice();
			newFileList.splice(index, 1);
			this.fileList = newFileList;
		},
		handleSubmit(e) {
			this.form.validateFields(async (err, values) => {
				if (!err) {
					let that = this;
					let data = {};
				}
			});
		}
	}
};
</script>

<style lang="less" scoped>
.aid .base {
	width: 700px;
	margin-left: -350px;
}
/deep/.ant-form {
	margin-top: 50px;
	padding-bottom: 50px;
}
/deep/.ant-form-item {
	margin: 20px 50px;
	display: flex;
}
/deep/.ant-form-item-label {
	width: 100px;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	text-align: right;
}
/deep/.ant-form-item-control-wrapper {
	flex: 1;
}
/deep/.ant-calendar-picker {
	width: 100% !important;
}
</style>
